#ifndef _FRAME_H_
#define _FRAME_H_

#include "../../input/Keys.h"
#include "Object.h"
#include <set>
#include <vector>

// Define the object list type so we don't retype it everywhere
typedef std::set<Object*, ObjectPointerLessThan> ObjectList;

/**
	This is a single instance of a GUI screen. Only one frame can be active at one time.
	It is a giant container class to hold all objects and do hit tests on them for input
*/
class Frame {
	ObjectList objs;					//All of the objects that belong to this frame
	fVec2D pos;						//Where this frame is aligned in the windowFrame
	fVec2D dimensions;					//The width and height
	ALIGNMENT horizalign, vertalign;		//What alignment the frame has
	
	std::vector<Object*> select(float x, float y);	//Get all objects that are hit by a click at (x,y)
	Object* select(KEY_TYPE b);					//Get the first object whose key is 'b'
public:
	Frame();
	~Frame();

	bool leftClick(float x, float y);		//When left clicked at (x,y), return if the hit test succeeded
	bool keyPress(KEY_TYPE);				//When key k is pressed, return if there was an object for the key
	void rollOver(float x, float y);		//When the mouse is at (x,y)
	
	void enable();						//enables this frame. Tells each object to enable
	void disable();					//disables this frame, tells each object to disable

	void onWindowResize(float, float);		//When the window resizes, tell everyone to realign
	
	void loadFromXML(ticpp::Node* node);	//Load this frame from the given node
	
	static void parseChild(ticpp::Node*, int, Frame*);	//global function to parse a node that will only have types of objects in it
};

#endif
